Skip to content

chore(executor): extract shared utils and remove dead code from handlers#3334

Merged
waleedlatif1 merged 1 commit intostagingfrom
cleanup-executor-handlers-dead-code
Feb 25, 2026
Merged

chore(executor): extract shared utils and remove dead code from handlers#3334
waleedlatif1 merged 1 commit intostagingfrom
cleanup-executor-handlers-dead-code

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Extract duplicated builder data conversion logic into executor/utils/builder-data.ts (used by response and HITL handlers)
  • Extract vertex credential resolution into executor/utils/vertex-credential.ts (used by agent handler)
  • Deduplicate MCP tool building in agent handler via shared buildMcpTool method
  • Remove dead code and unused imports across executor handlers
  • Add .claude/launch.json and .claude/worktrees/ to gitignore

Type of Change

  • Refactoring / cleanup (no behavior change)

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Building Building Preview, Comment Feb 25, 2026 7:16pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR extracts duplicated code into shared utilities and removes unused code across executor handlers. Two new utility files (builder-data.ts and vertex-credential.ts) centralize previously duplicated logic from multiple handlers. The refactoring also includes two small bug fixes: replacing DEFAULTS.EXECUTION_TIME (value: 0) with the correct semantic values 0 for metric scores and ?? 0 for tool call counts.

Key Changes:

  • Extracted builder data conversion logic into executor/utils/builder-data.ts (used by response and HITL handlers)
  • Extracted vertex credential resolution into executor/utils/vertex-credential.ts (used by agent, evaluator, and router handlers)
  • Deduplicated MCP tool building logic in agent handler via new buildMcpTool method
  • Removed ~45 lines of dead code (flattenChildWorkflowSpans) from workflow handler
  • Fixed semantic bugs where DEFAULTS.EXECUTION_TIME was incorrectly used instead of literal 0
  • Added Claude Code files to .gitignore

The refactoring is well-executed with proper extraction patterns, maintained backwards compatibility (static method wrapper in ResponseBlockHandler), and consistent implementation across all handlers.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • Clean refactoring with proper code extraction, no behavior changes, maintained backwards compatibility, and includes small bug fixes that improve code correctness
  • No files require special attention

Important Files Changed

Filename Overview
.gitignore Added Claude Code config files to gitignore
apps/sim/executor/utils/builder-data.ts New utility extracting shared builder data conversion logic from response and HITL handlers
apps/sim/executor/utils/vertex-credential.ts New utility extracting vertex credential resolution from agent, evaluator, and router handlers
apps/sim/executor/handlers/agent/agent-handler.ts Extracted vertex credential util, added buildMcpTool method to deduplicate logic, fixed bug using ?? 0 instead of DEFAULTS.EXECUTION_TIME for toolCalls count
apps/sim/executor/handlers/evaluator/evaluator-handler.ts Uses shared vertex credential util, fixed bug replacing DEFAULTS.EXECUTION_TIME with 0 for metric scores
apps/sim/executor/handlers/human-in-the-loop/human-in-the-loop-handler.ts Uses shared builder data utils, removed 140+ lines of duplicated conversion logic and static method
apps/sim/executor/handlers/response/response-handler.ts Uses shared builder data utils, removed 140+ lines of duplicated logic, kept static wrapper method for backwards compatibility
apps/sim/executor/handlers/router/router-handler.ts Uses shared vertex credential util, removed duplicate vertex resolution method and unused imports
apps/sim/executor/handlers/workflow/workflow-handler.ts Removed unused flattenChildWorkflowSpans method (45 lines of dead code)

Last reviewed commit: 21b857c

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1 waleedlatif1 merged commit 8b0c47b into staging Feb 25, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the cleanup-executor-handlers-dead-code branch February 25, 2026 19:28
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant